﻿using System;

namespace msBsc.WebUi.wMall.Public
{
    public partial class wfAccountVerify : msBsc.Cls.BPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                string stremkey=this.GetFormParam("KEY");
                if(stremkey==string.Empty)
                {
                    //this.ExecJScript("window.location.href = '/c_RegMailSend.htm';");
                    return;
                }
                stremkey=msBsc.AppLogic.Cfg.DesCry.uncMe(stremkey,"rmdes");
                string[] arrten=stremkey.Split(',');
                if(arrten.Length < 3)
                {
                    //this.ExecJScript("window.location.href = '/c_RegMailSend.htm';");
                    return;
                }
                //DateTime dtreg=DateTime.Now.AddDays(-2);
                //if(!DateTime.TryParse(arrten[1],out  dtreg) || dtreg<DateTime.Now.AddDays(-1))
                //{
                //    this.ExecJScript("reRegister();");
                //    //this.ExecJScript("window.location.href = '/c_RegMailSend.htm';");
                //    return;
                //}
                //this.ExecJScript("$('#spnMailNme').html('" + arrten[0] + "')");
                //this.ExecJScript("LS.set('CURR_REG_MAIL','" + arrten[0] + "');");
                //this.ExecJScript("if(LS.get('" + arrten[0] + "') && LS.get('" + arrten[0] + "') != 'STEP3'){ LS.set('" + arrten[0] + "','STEP2');}");
                //this.ExecJScript("LS.set('" + arrten[0] + "_RDT','" + DateTime.Now.ToString() + "');");
                //this.ExecJScript("validateStep();");
                //if (arrten.Length > 2)
                //{
                //    this.ExecJScript("$('#txtPROMOTION_NME').val('" + arrten[2] + "')"); 
                //}
            }
        }
        public override void DoAction()
        {
            if (this.strAction == "doVerify")
            {
                string stremkey = this.GetParamHtValue("KEY");
                if (stremkey != string.Empty)
                {
                    if (stremkey == string.Empty)
                    { 
                        return;
                    }
                    stremkey = msBsc.AppLogic.Cfg.DesCry.uncMe(stremkey, "rmdes");
                    string[] arrten = stremkey.Split(',');
                    if (arrten.Length < 3)
                    {
                        //this.ExecJScript("window.location.href = '/c_RegMailSend.htm';");提示错误链接失效
                        return;
                    }
                    using (msBsc.AppLogic.DataAlc.CBizCustomerRegister register=new AppLogic.DataAlc.CBizCustomerRegister())
                    {
                        string[] retArry = register.UserActivation(arrten[0], arrten[4]);
                        if (retArry[0]!="TRUE")
                        {
                            this.ExecJScript(@"ValidationFails('" + retArry[1] + "')");
                            return;
                        }
                    }
                    string ret = msBsc.SvRef.UserInfo.LoginCustomer(arrten[0], arrten[1]);
                    if (ret != "OK")
                    {
                        //this.SetContrlValue("login_notice", ret);提示错误
                    }
                    else
                    {
                        this.SetContrlValue("AccountNumber", msBsc.SvRef.UserInfo.OperatorName);
                        string url = "/wb_TouristInfo.htm";
                        this.ExecJScript(@"TimeDown('" + url + "')");
                        //this.ExecJScript("window.location.href = '/wb_TouristInfo.htm?djackId="+msBsc.SvRef.UserInfo.Operator+"';");
                        
                        //this.ExecJScript(@"setCookie('" + account + "','" + password + "');susccLogin()");
                    }

                }
            }
        }
    }
}